function refreshProgress(selector) {
//	UploadMonitor.getUploadInfo(updateProgress);
	var formSelector = selector;
	UploadMonitor.getUploadInfo(function(uploadInfo){
		if (uploadInfo.inProgress) {
			jQuery("#avatarFile").hide();
			
			var fileIndex = uploadInfo.fileIndex;
			
			var progressPercent = Math.ceil((uploadInfo.bytesRead / uploadInfo.totalSize) * 100);
			var width = parseInt(progressPercent * 3.5)+ 'px';
			
			if(!formSelector){
				jQuery("#progressBarText").html('Đang upload:' + progressPercent + '%');
				jQuery('#progressBarBoxContent').css('width', width);
				window.setTimeout('refreshProgress()', 1000);
			}else{
				var $form = jQuery(formSelector);
				var $progressBar = $form.siblings('#progressBar');
				$progressBar.find('#progressBarBoxContent').css('width', width);
				$progressBar.find('#progressBarText').html("Đang upload: "+progressPercent+"%");
				window.setTimeout("refreshProgress('"+formSelector+"')", 1000);
			}
			
		} else {
			jQuery('#avatarFile').show();
		}

		return true;
	});
}

function updateProgress(uploadInfo) {
	if (uploadInfo.inProgress) {
		jQuery("#avatarFile").hide();

		var fileIndex = uploadInfo.fileIndex;

		var progressPercent = Math.ceil((uploadInfo.bytesRead / uploadInfo.totalSize) * 100);

		jQuery("#progressBarText").html('Đang upload:' + progressPercent + '%');
		
		var width = parseInt(progressPercent * 3.5)+ 'px';
		jQuery('#progressBarBoxContent').css('width', width);

		window.setTimeout('refreshProgress()', 1000);
	} else {
		jQuery('#avatarFile').show();
	}

	return true;
}

function startProgress(selector) {
	if(!selector){
		jQuery('#progressBarBoxContent').css('width', '0px');
		jQuery('#progressBar').show();
		jQuery('#progressBarText').html("Đang upload: 0%");		
		window.setTimeout('refreshProgress()', 1500);
	}else{		
		var $form = jQuery(selector);
		var $progressBar = $form.siblings('#progressBar');
		$progressBar.find('#progressBarBoxContent').css('width', '0px');
		$progressBar.show();
		$progressBar.find('#progressBarText').html("Đang upload: 0%");
		// wait a little while to make sure the upload has started ..
		window.setTimeout("refreshProgress('"+selector+"')", 1500);
	}
	
	
	return true;
}
